<div ng-controller="Finance_ClientAccountC">

    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">客户名称 -- {{$stateParams.name}}</h1>
    </div>
    <div class="wrapper-md" style="text-align: center;">
        <div class="panel panel-default">
            <div class="panel-heading text-right">
                <button type="button" class="btn btn-default" ng-click="$state.go('app.Finance_AccountList')">返回</button>
            </div>
            <div class="table-responsive">
                <table id="example1" class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th style="text-align: center;">户头名称</th>
                        <th style="text-align: center;">户头余额</th>
                        <th style="text-align: center;">信息</th>
                        <th style="text-align: center;">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="item in pageData.Accounts">
                        <td style="width: 30%">{{item.Name}}</td>
                        <td style="width: 10%">{{item.Amount | number:2}}</td>
                        <td style="width: 40%">{{item.BankName}}--{{item.BankNumber}}</td>

                        <td style="width: 20%">
                            <button class="btn btn-sm btn-default" ng-click="$state.go('app.Finance_Flow', { 'id': item.Id,'name':item.Name })">
                                <i class="fa fa-list text"></i>
                                <span class="text">户头流水</span>
                            </button>
                            <!--<button type="button" class="btn" ng-click="refund(item)">退款</button>-->
                        </td>

                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


<script>
    angular.module('app')//非标优惠
            .controller("Finance_ClientAccountC", function ($scope, $state, $http,$stateParams) {
                $scope.pageData = {};
                //
//                $scope.refund = function(item){
//                    if(item.Amount>0){
//                        if(confirm("退款金额："+item.Amount+",确认提交退款申请?")){
//                            $http({
//                                url:"../api/ClientManager/ApplyRefund?AccountId="+item.Id,
//                                method:"POST"
//                            })
//                                    .then(function (res) {
//                                        if (res.State <= 0) {
//                                            alert(res.Msg);
//                                        } else {
//                                            alert("已提交退款申请");
//                                            $state.go('app.Customer_MyAccountList', { 'id': $stateParams.id });
//                                        }
//                                    })
//                        }
//                    }else{
//                        alert("余额不足！")
//                    }
//                };
                $scope.getData = function () {
                    $http({
                        url: "/api/Customer/Detail?id="+$stateParams.id,
                        method: "GET"
                    })
                            .then(function (res) {
                                $scope.pageData = res.data;
                                console.log($scope.pageData);
                            })
                            .then(function (error) {
                                if (error) {
                                    alert("数据获取失败");
                                }
                            });
                };
                $scope.getData();


            })

</script>
